package com.atguigu.config;

import com.atguigu.bean.Person;
import com.atguigu.service.BookService;
import org.springframework.context.annotation.*;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Service;

/**
 * @author 张晓
 * @create 2020-11-17 14:00
 */
//配置类==配置文件
@Configuration      //告诉Spring 这是一个配置类
@ComponentScans(value = {@ComponentScan(value = "com.atguigu", includeFilters = {
        /*@ComponentScan.Filter(type = FilterType.ANNOTATION, value = {Controller.class}),
        @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE,classes = {BookService.class}),*/
        @ComponentScan.Filter(type = FilterType.CUSTOM,classes = {MyTypeFilter.class})
}, useDefaultFilters = false)})
//@ComponentScan(value = "com.atguigu",excludeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION,value = {Controller.class, Service.class})
//})
//@ComponentScan(value = "com.atguigu", includeFilters = {
//        @ComponentScan.Filter(type = FilterType.ANNOTATION, value = {Controller.class, Service.class})
//}, useDefaultFilters = false)
//@ComponentScan value:指定要扫描的包
//excludeFilters = Filter[] :指定扫描的时候按照什么规则排除哪些组件
//includeFilters = Filter[] :指定扫描的时候只需要包含哪些组件
//FilterType.ANNOTATION :按照注释
//FilterType.ASSIGNABLE_TYPE :按照给定的类型
//FilterType.ASPECTJ :使用ASPECTJ表达式
//FilterType.REGEX :使用正则指定
//FilterType.CUSTOM :使用自定义规则
public class MainConfig {

    //给容器中注册一个Bean;类型为返回值的类型，id默认是用方法名作为id
    @Bean("person")
    public Person person01() {
        return new Person("lisi", 20);
    }

}
